<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class LoginRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'mobile' => ['required', 'regex:/^1\d{10}$/', Rule::exists('admins')],
            'password' => ['required', 'between:6,18'],
//            'captcha.content' => ['required', 'captcha_api:' . request('captcha.key') . ',default']
        ];
    }

    public function attributes()
    {
        return [
            'mobile' => '手机号', 'password' => '密码', 'captcha.content' => '图形验证码',
        ];

    }

    public function messages()
    {
        return [
            'captcha.content.captcha_api' => '验证码输入错误'
        ];
    }

}
